<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateTableHireEventApplicationLogs extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('feishu_event_logs', function (Blueprint $table) {
            $table->id();
            $table->string('schema')->default('')->comment('事件格式的版本。无此字段的即为1.0');
            $table->string('eventId')->default('')->comment('事件的唯一标识');
            $table->string('token')->default('')->comment('Verification Token');
            $table->string('eventCreateTime')->default('')->comment('事件发送的时间');
            $table->string('eventType')->default('')->comment('事件类型');
            $table->string('tenantKey')->default('')->comment('企业标识');
            $table->string('appId')->default('')->comment('应用Id');
            $table->json('eventData')->default('')->comment('事件数据');

//            $table->string('applicationId')->default('')->comment('投递 ID');
//            $table->string('originStageId')->default('')->comment('旧阶段');
//            $table->string('targetStageId')->default('')->comment('新阶段');
//            $table->string('updateTime')->default('')->comment('新更新时间阶段');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->index('eventType', 'idx_event_type');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '飞书事件通知表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('feishu_event_logs');
    }
}
